#ifndef __DOUBLELINKLIST_H__
#define __DOUBLELINKLIST_H__


#define ElementType int
struct Node
{
    ElementType data;
    struct Node* prev;
    struct Node* next;
};
typedef struct DBLinkList
{
    struct Node* head;
    struct Node* tail;
    int len;
}DBL;

extern int InitDBLinkList(DBL* list);
extern struct Node* CreateNode(ElementType element);
extern void InsertTail(DBL* list, ElementType element);
extern void FreeDBLList(DBL* list);
extern void Travel(DBL* list);
extern void InsertHead(DBL* list, ElementType element);
extern void InsertByIndex(DBL* list, ElementType element, int index);
extern void RemoveByIndex(DBL* list, int index);

int FindFirstByElement(DBL* list, ElementType element);
extern void RemoveByElement(DBL* list, ElementType element);

extern ElementType* FindByIndex(DBL* list, int index);
extern int* FindByElement(DBL* list, ElementType element);
extern void SetValueByIndex(DBL* list, int index, ElementType element);
extern void SetValueByElement(DBL* list, ElementType old_element, ElementType new_element);

extern void BubbleSort(DBL* list);

#endif